package com.lzj.firewallmamager.controller;

import com.lzj.firewallmamager.entity.FirewallPolicyEntity;
import com.lzj.firewallmamager.service.FirewallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class FirewallController {

    @Autowired
    private FirewallService service;

    @PostMapping("/addPolicy")
    public String addPolicy(@RequestBody FirewallPolicyEntity entity) throws Exception {
        service.insertPolicy(entity);

        return "success";
    }

    @GetMapping("/getPolicyById/{id}")
    public FirewallPolicyEntity getPolicyById(@PathVariable Integer id) throws Exception {
        return service.getPolicyById(id);
    }

    @GetMapping("/getAllPolicy")
    public List<FirewallPolicyEntity> getAllPolicy(@RequestParam int pageNum, @RequestParam int pageSize) throws Exception {
        return service.getAllPolicy(pageNum, pageSize);
    }
}
